<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1,user-scalable=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <title>{$title}</title>
    <css href="__PUBLIC__/css/reset.css"/>
    <css href="__PUBLIC__/css/style.css"/>
    <css href="__PUBLIC__/css/bootstrap.min.css"/>
    <css href="__PUBLIC__/css/bootstrapValidator.css"/>
    <css href="__PUBLIC__/css/mregister.css"/>
    <js href="__PUBLIC__/js/Jquery/jquery-1.js"/>
    <js href="__PUBLIC__/js/bootstrapValidator.js"/>
    <script language="JavaScript">
        /**
         * 发送邮件检查
         */
        function get_mobile_code(){
            //var username=document.getElementById('username').value;
            //var reg=/^(13[0-9]|15[0|1|2|3|6|7|8|9]|18[0|2|3|5|6|7|8|9]|17[0])\d{8}$/;
            var username=document.getElementById('username').value;
            var reg=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
            var result=document.getElementById("result");
            var messages=document.getElementById("messages");
            var res=username.match(reg);
            if(res){
                $.post("<?php echo U('/code');?>",{username:username},function (msg){
                    if(msg=="0"){
                        document.getElementById('errorImg').src="__PUBLIC__/images/tick.png";
                        messages.innerHTML="邮件发送成功。";
                        result.style.display="block";
                        $(" #result").fadeOut(5000);
                        RemainTime();
                    }else if(msg=="1"){
                        document.getElementById('errorImg').src="__PUBLIC__/images/error.jpg";
                        messages.innerHTML="邮件发送失败。";
                        result.style.display="block";
                    }else if(msg=="2"){
                        document.getElementById('errorImg').src="__PUBLIC__/images/error.jpg";
                        messages.innerHTML="该邮箱已经被注册了。";
                        result.style.display="block";
                    }else{
                        alert(msg);
                    }
                });
            }else{
                document.getElementById('errorImg').src="__PUBLIC__/images/error.jpg";
                messages.innerHTML="请填写正确的邮箱格式。";
                result.style.display="block";
                document.getElementById('username').focus();
            }
        }

        /**
         * 注册第一步验证
         */
        function mstregCheck(){
            //var username=document.getElementById('username').value;
            //var reg=/^(13[0-9]|15[0|1|2|3|6|7|8|9]|18[0|2|3|5|6|7|8|9]|17[0])\d{8}$/;
            var username=document.getElementById('username').value;
            var reg=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
            var result=document.getElementById("result");
            var messages=document.getElementById("messages");
            var verify=document.getElementById('verify').value;
            var res=username.match(reg);
            if(res){
                $.post("<?php echo U('/mstregCheck');?>",{username:username,verify:verify},function (msg){
                    if(msg=="0"){
                        result.style.display="none";
                        if(result.style.display=="none"){
                            window.location.href="<?php echo U('/mndreg');?>";
                        }else{
                            document.getElementById('errorImg').src="__PUBLIC__/images/error.jpg";
                            messages.innerHTML="错误信息未处理完成。";
                            result.style.display="block";
                        }
                    }else if(msg=="1"){
                        document.getElementById('errorImg').src="__PUBLIC__/images/error.png";
                        messages.innerHTML="验证码错误。";
                        result.style.display="block";
                    }else if(msg=="2"){
                        messages.innerHTML="该邮箱已经被注册了。";
                        result.style.display="block";
                    }else if(msg=="3"){
                        document.getElementById('errorImg').src="__PUBLIC__/images/error.jpg";
                        messages.innerHTML="请填写正确的邮箱格式。";
                        result.style.display="block";
                    }else{
                        alert(msg);
                    }
                });
            }else{
                document.getElementById('errorImg').src="__PUBLIC__/images/error.jpg";
                messages.innerHTML="请填写正确的邮箱格式。";
                result.style.display="block";
                document.getElementById('username').focus();
            }
        }

        var iTime = 59;
        var Account;
        /**
         * 60秒倒数
         * @constructor
         */
        function RemainTime(){
            document.getElementById('zphone').disabled = true;
            var iSecond,sSecond="",sTime="";
            if (iTime >= 0){
                iSecond = parseInt(iTime%60);
                iMinute = parseInt(iTime/60)
                if (iSecond >= 0){
                    if(iMinute>0){
                        sSecond = iMinute + "分" + iSecond + "秒";
                    }else{
                        sSecond = iSecond + "秒后重新发送";
                    }
                }
                sTime=sSecond;
                if(iTime==0){
                    clearTimeout(Account);
                    sTime='获取邮箱验证码';
                    iTime = 59;
                    document.getElementById('zphone').disabled = false;
                }else{
                    Account = setTimeout("RemainTime()",1000);
                    iTime=iTime-1;
                }
            }else{
                sTime='没有倒计时';
            }
            document.getElementById('zphone').value = sTime;
        }
    </script>
</head>
<body>
<include file="./Application/Home/View/nav.html"/>
<div class="container">
    <div class="row" style="margin-top:20px;">
        <div class="col-lg-6">
            <img src="__PUBLIC__/images/LOGO.png" class="img-responsive"/>
        </div>
    </div>

    <div class="row" style="margin-top:20px;">
        <div class="col-lg-6">
            <img src="__PUBLIC__/images/people.png" class="img-responsive"/>
        </div>
        <div class="col-lg-6">
            <section>
                <form role="form" novalidate="novalidate" id="mregister-form" method="post" class="form-horizontal bv-form">

                    <div id="mregister-title">
                        <span>
                            <div style="float: left;">///////////////////</div>
                            <label>注册</label>
                            <div style="float: right;">///////////////////</div>
                        </span>
                    </div>

                    <!--error tips-->
                    <include file="./Application/Home/View/error_tips.html"/>

                    <div id="mregister-content">
                        <div class="form-group has-feedback" style="height: 50px; padding-top: 15px; margin-left: 2px;">
                            <label for="username" class="col-sm-2 control-label">邮箱</label>
                            <!--<input type="text" data-bv-field="username" name="username" id="username" class="form-control col-sm-10" required="required" placeholder="请输入您的手机号码" maxlength="11"/>-->
                            <input type="text" data-bv-field="username" name="username" id="username" class="form-control col-sm-10" required="required" placeholder="请输入您的邮箱"/>
                        </div>
                        <div class="form-group form-verify" style="height: 50px; padding-top: 15px; margin-left: 2px;">
                            <label for="verify" class="col-sm-2 control-label">验&nbsp;证&nbsp;码</label>
                            <input type="text" name="verify" id="verify" class="form-control col-sm-10" required="required" maxlength="6"/>
                            <input type="button" id="zphone" onclick="get_mobile_code()" class="btn btn-default" style="width: 36%; height: 40px; background-color: #ff2d4b; color: #ffffff; font-size: 15px; font-weight:bold; border-radius:6px; font-family: Arial,'宋体';" value="获取邮箱验证码">
                        </div>
                    </div>

                    <div id="mregister-bottom">
                        <div class="form-group">
                            <div class="col-sm-offset-3 col-sm-10">
                                <input type="button" onclick="mstregCheck()" class="btn btn-default btn-lg active" value="下一步"/>
                            </div>
                        </div>
                        <div style="float: right; margin-right: 20px; padding-bottom: 20px;color: #afafaf; font-size: 20px;font-family: '微软雅黑,宋体';">
                            <a class="help-block" href="{:U('/login')}">快速登录&gt;&gt;</a>
                        </div>
                    </div>
                </form>
            </section>
            <script type="text/javascript">
                $(document).ready(function () {
                    // Generate a simple captcha
                    function randomNumber(min, max) {
                        return Math.floor(Math.random() * (max - min + 1) + min);
                    };
                    $('#captchaOperation').html([randomNumber(1, 100), '+', randomNumber(1, 200), '='].join(' '));

                    $('#mregister-form').bootstrapValidator({
                    //        live: 'disabled',
                        message: '输入无效',
                        feedbackIcons: {
                            valid: 'glyphicon glyphicon-ok',
                            invalid: 'glyphicon glyphicon-remove',
                            validating: 'glyphicon glyphicon-refresh'
                        },
                        fields: {
                            /*username: {
                                message: '无效手机号',
                                validators: {
                                    notEmpty: {
                                        message: '手机号不能为空'
                                    },
                                    regexp: {
                                        regexp: /^(13[0-9]|15[0|1|2|3|6|7|8|9]|18[0|2|3|5|6|7|8|9]|17[0])\d{8}$/,
                                        message: '手机号格式必须正确且由11位数字组成'
                                    }
                                }
                            },*/
                            username: {
                                message: '无效邮箱',
                                validators: {
                                    notEmpty: {
                                        message: '邮箱不能为空'
                                    },
                                    regexp: {
                                        regexp: /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/,
                                        message: '邮箱格式不正确'
                                    }
                                }
                            },
                            verify:{
                                message:'非法验证码',
                                validators:{
                                    notEmpty:{
                                        message:'验证码不能为空'
                                    },
                                    regexp:{
                                        regexp:/^\d{6}$/,
                                        message:'验证码必须由6为数字组成'
                                    }
                                }
                            }
                        }
                    });

                    // Validate the form manually
                    $('#validateBtn').click(function () {
                        $('#mregister-form').bootstrapValidator('validate');
                    });

                    $('#resetBtn').click(function () {
                        $('#mregister-form').data('bootstrapValidator').resetForm(true);
                    });
                });
            </script>
        </div>
    </div>
</div>
<!--	引入底部	-->
<include file="./Application/Home/View/footer.html"/>
</body>
</html>